package hotciv.view.tool;

import java.awt.event.MouseEvent;

import hotciv.framework.*;
import hotciv.view.GfxConstants;
import minidraw.framework.DrawingEditor;
import minidraw.standard.NullTool;

public class InspectTool extends NullTool 
{
	private Game game;
	private DrawingEditor editor;

	public InspectTool(DrawingEditor editor, Game game) 
	{
		this.editor = editor;
		this.game = game;
	}

	public void mouseUp(MouseEvent e, int x, int y) 
	{
		Position p = GfxConstants.getPositionFromXY(x, y);
		City city = game.getCityAt(p);
		Unit unit = game.getUnitAt(p);

	
		if (unit != null && city != null) 
		{
			editor.showStatus("Inspecting " + unit.getOwner() + " " + unit.getTypeString() + " in a " + city.getOwner() + " city");
		}
		else if (unit != null) 
		{
			editor.showStatus("Inspecting " + unit.getOwner() + " " + unit.getTypeString());
		}
		else if (city != null) 
		{
			editor.showStatus("Inspecting " + city.getOwner() + " city");
		} 
		game.setTileFocus(p);

	}
}